package java67_adv10;

import java.io.File;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class ReadXML2 {

	public static void main(String[] args) {
		SAXReader reader = new SAXReader();
		Document doc = null;
		try {
			doc = reader.read(new File("src/java67_adv10/courses.xml"));
		} catch (DocumentException e) {
			System.out.println("文档出问题了");
			e.printStackTrace();
			return;
		}
		// >>>要显示课时大于15的课程信息
		List<Element> list = doc.selectNodes("/courses/course[coursetime>15]");
		for (Element e : list) {
			// e.selectNodes("name").get(0);
			Element ename = (Element) e.selectSingleNode("name");
			System.out.println(ename.getText());
			Element etime = (Element) e.selectSingleNode("coursetime");
			int time = Integer.parseInt(etime.getText());
			System.out.println("时长:" + time);
			System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
		}
	}

}
